

function isArrSame(arr1, arr2) {
    if (arr1.length !== arr2.length) return false;
    
    const set = [...new Set([...arr1, ...arr2])]
    function getCounts(arr) {
      return set.map(item => arr.filter(ele => [ele].includes(item)).length).join('')
    }
    console.log(getCounts(arr1));
    
    return getCounts(arr1) === getCounts(arr2)
  }
  

  const array1 = ["apple", "banana", "cherry", "banana",];
  const array2 = ["banana", "apple", "banana", "cherry",];
  isArrSame(array1,array2)
  console.log("🚀 ~ file: tets.js:19 ~  isArrSame(array1,array2):",  isArrSame(array1,array2))
